import React, { Component, PropsWithChildren } from 'react'
import { RouteComponentProps } from 'react-router-dom'
import 'reset-css'
import './style.scss'

interface Props extends PropsWithChildren, RouteComponentProps {}
class App extends Component<Props> {
  // 路由拦截
  handleRoute = () => {
    const { location, history } = this.props
    const { pathname } = location

    // 跳转首页
    if (pathname === '/') {
      history.push('index')
      return false
    }
    return true
  }
  render() {
    const { children } = this.props
    return <>{this.handleRoute() ? children : 'other'}</>
  }
}
export default App
